﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using System.Windows.Media;

using Aliphant.Mvvm.XEvent.UI;

namespace TestModule.ViewModels
{
    public class WidgetClockViewModel : BindableBase
    {

        private string _colorHex = "ffffff";
        public string ColorHex { get => _colorHex; set => SetProperty(ref _colorHex, value); }

        private Brush _clockColor = Brushes.White;
        public Brush ClockColor { get => _clockColor; set => SetProperty(ref _clockColor, value); }

        public ICommand SetColorCommand
        {
            get => new UICommand<object>(obj =>
            {
                string hex = ColorHex;
                if (!hex.StartsWith("#"))
                {
                    hex = "#" + hex;
                }

                var color = (Color?)ColorConverter.ConvertFromString(hex);
                if (color == null)
                {
                    return;
                }

                var brush = new SolidColorBrush(color.Value);
                ClockColor = brush;
            });
        }
    }
}
